package server

import (
	"shop-manager/internal/logic"
	"shop-manager/internal/repos/category"
	"shop-manager/internal/repos/contract"
	"shop-manager/internal/repos/factory_rebate"
	"shop-manager/internal/repos/goods"
	"shop-manager/internal/repos/person"
	"shop-manager/internal/repos/salesperson"
	"shop-manager/internal/repos/supermarket"
	"shop-manager/internal/repos/supermarket_director"

	"github.com/gin-gonic/gin"
	"github.com/google/wire"
)

var ProviderSet = wire.NewSet(
	NewEngine,
	NewServer,
)

//go:generate newc
type Server struct {
	engine *gin.Engine

	categoryRepo  *category.CategoryRepo
	categoryLogic *logic.CategoryLogic

	supermarketRepo *supermarket.SupermarketRepo

	salesPersonLogic *logic.SalesPersonLogic
	salesPersonRepo  *salesperson.SalesPersonRepo

	personLogic *logic.PersonLogic
	personRepo  *person.PersonRepo

	supermarketDirectorRepo  *supermarket_director.SupermarketDirectorRepo
	supermarketDirectorLogic *logic.SupermarketDirectorLogic

	goodsRepo  *goods.GoodsRepo
	goodsLogic *logic.GoodsLogic

	factoryRebateRepo  *factory_rebate.FactoryRebateRepo
	factoryRebateLogic *logic.FactoryRebateLogic

	contractRepo  *contract.ContractRepo
	contractLogic *logic.ContractLogic
}

func (s *Server) Run(addr ...string) error {
	if err := s.Route(); err != nil {
		return err
	}
	return s.engine.Run(addr...)
}
